package day3;

import day2.el.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

@WebServlet("/day3/each")
public class EachDemo extends HttpServlet{
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String[]arrs = {"赵雅芝","小苍","小泽"};
        req.setAttribute("arrs", arrs);

        User u1 = new User(1,"a1");
        User u2 = new User(2,"a2");
        req.setAttribute("list", Arrays.asList(u1,u2));

        Map<Integer,User> m = new HashMap<Integer,User>();
        m.put(u1.getId(), u1);
        m.put(u2.getId(), u2);
        req.setAttribute("m",m);
        req.getRequestDispatcher("/day3/each.jsp").forward(req,resp);
    }
}
